<template>
  <div id="app">
    <el-container class="tools-body_wrapper">
      <el-aside style="background-color: #2c405a;">
        <h1><mds-icon type="line-toolbox" /><span class="title">EP-Toolkit</span></h1>
        <mds-menu
          :defaultSelectedKeys="defaultSelectedKeys"
          mode="inline"
          style="width: 100%;"
          model="inline"
          theme="dark"
          @click="menuItemClick"
        >
          <mds-menu-item v-for="item in menuItemList" :key="item.index" :index="item.index"> <mds-icon :type="item.icon || 'line-image-search'" />{{ item.name }}</mds-menu-item>
        </mds-menu>
      </el-aside>
      <el-main style="padding-top: 0">
        <router-view></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import menuItemList from './config/menuItem'

export default {
  name: 'toolkit',
  data() {
    return {
      menuItemList,
      defaultSelectedKeys:  menuItemList && menuItemList[0] ? [menuItemList[0].index] : ['matching'],
      selectedKeys: menuItemList && menuItemList[0] ? menuItemList[0].index : '',
    }
  },
  mounted() {},
  methods: {
    menuItemClick(e) {
      if (e) {
        const { index } = e
        if (index !== this.selectedKeys) {
          const item = this.menuItemList.find(i => i.index === index)
          this.selectedKeys = index
          if (item && item.path) {
            this.$router.push({
              path: item.path
            })
          }
        }
      }
    }
  }
};
</script>

<style lang="scss">
#app {
  width: 100%;
  height: 100%;
}
h1 {
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  .title {
    font-size: 22px;
    display: inline-block;
    padding-left: 18px;
  }
}
.tools-body_wrapper {
  width: 100%;
  height: 100%;
  .mds-layout-content {
    background-color: #fff;
  }
}
</style>
